<template>
  <div class="app-container">
    <el-form ref="ruleForm" :model="formData" :rules="rules" label-width="100px" class="demo-ruleForm">
      <el-form-item label="提醒邮箱" prop="emails">
        <el-input v-model="formData.emails" type="textarea" placeholder="不同邮箱之间用英文逗号分隔" rows="4" />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="submit('ruleForm')">提交</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script type="text/ecmascript-6">
export default {
  props: {
    formData: {
      type: Object,
      default() {
        return {
          emails: []
        }
      }
    }
  },
  data() {
    return {
      rules: {
        emails: [
          { required: true, message: '请输入邮箱号', trigger: 'blur' }
        ]
      }
    }
  },
  methods: {
    submit(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          this.$emit('sendMessageSubmit', this.formData)
        } else {
          console.log('error submit!!')
          return false
        }
      })
    }
  }
}
</script>

<style lang="scss" scoped>

</style>
